package march.test_3_3;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class TestMain3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while(true) {
            int n = scanner.nextInt();
            if(n == 0) {
                break;
            } else {
                list.add(n);
            }
        }
        int[] arr = new int[list.size()];
        for(int i = 0; i < list.size(); i++) {
            arr[i] = drink(list.get(i));
        }
        for(int i = 0; i < arr.length ;i++) {
            System.out.println(arr[i]);
        }
    }
    public static int drink(int n) {
        int count = 0;
        for(int i = n; i > 1; i = i / 3 + i % 3) {
            if(i == 2) {
                count += 1;
                break;
            } else {
                count += i/3;
            }
        }
        return count;
    }
}
